package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface UserMapper {
    /**
     * 根据openid查询
     * */
    @Select("select * from user where openid = #{openid}")
    User getByOpenid(String openid);
    @Insert("insert into user(openid,name,create_time) values (#{openid},#{name},#{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addUser(User user);
    /**
     * 根据id查询
     * */
    @Select("select * from user where id = #{id}")
    User getById(Long id);
    /**
     * 统计一天新增用户
     * */
    Long countByMap(Map map);
}
